//
//  PersonalDetailHeaderTableViewCell.m
//  CarTown
//
//  Created by xionghao on 15/8/5.
//  Copyright (c) 2015年 熊浩. All rights reserved.
//

#import "PersonalDetailHeaderTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "ShopHeaderModel.h"
#import "SDPhotoBrowser.h"
@interface PersonalDetailHeaderTableViewCell ()<SDPhotoBrowserDelegate>

@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UIImageView *typeicon;
@property (weak, nonatomic) IBOutlet UILabel *typestring;
@property (weak, nonatomic) IBOutlet UIView *contenterbgview;

@end

@implementation PersonalDetailHeaderTableViewCell
+(instancetype)cellWithTable:(UITableView *)tableview{
    PersonalDetailHeaderTableViewCell *cell=[tableview dequeueReusableCellWithIdentifier:@"detail"];
    if (cell==nil) {
        [tableview registerNib:[UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil] forCellReuseIdentifier:@"detail"];
        cell=[tableview dequeueReusableCellWithIdentifier:@"detail"];
    }
    return cell;
}
- (void)awakeFromNib {
    // Initialization code
    self.headpic.layer.cornerRadius=self.headpic.width/2;
    self.headpic.layer.borderColor=[tintblue CGColor];
    self.headpic.layer.borderWidth=0.5;
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headcilck)];
    [self.headpic addGestureRecognizer:tap];
    self.headpic.userInteractionEnabled=YES;
}

-(void)headcilck{
    SDPhotoBrowser *photobroser=[[SDPhotoBrowser alloc]init];
    photobroser.delegate=self;
    photobroser.imageCount=1;
    photobroser.currentImageIndex=0;
    photobroser.sourceImagesContainerView=self.contenterbgview;
    [photobroser show];
    
}
-(UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index{
    return self.headpic.image;
}

-(void)setHeadermode:(ShopHeaderModel *)headermode{
    _headermode=headermode;
    [self.headpic sd_setImageWithURL:[NSURL URLWithString:[NSString getImageURLstr:_headermode.headpic]] placeholderImage:[UIImage imageNamed:@"usericon_placehoder"]];
    self.name.text=_headermode.headname;
    self.typestring.text=_headermode.shoptype;
    if ([_headermode.shoptype isEqualToString:@"个人商铺"]) {
        self.typeicon.image=[UIImage imageNamed:@"ico_p"];
    }else if ([_headermode.shoptype isEqualToString:@"综合销售店"]){
        self.typeicon.image=[UIImage imageNamed:@"ico_zonghe"];
    }else if ([_headermode.shoptype isEqualToString:@"4s店"]){
        self.typeicon.image=[UIImage imageNamed:@"ico_4s"];
    }else if ([_headermode.shoptype isEqualToString:@"资源公司"]){
        self.typeicon.image=[UIImage imageNamed:@"ico_z"];
    }else if ([_headermode.shoptype isEqualToString:@"港口批发商"]){
        self.typeicon.image=[UIImage imageNamed:@"ico_hk"];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
